/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author FIRE
 */
import { defHttp } from '/@/utils/http/axios';
import { useGlobSetting } from '/@/hooks/setting';
import { BasicModel, Page } from '../model/baseModel';
import { UploadApiResult } from '../sys/upload';
import { UploadFileParams } from '/#/axios';

const { ctxPath, adminPath } = useGlobSetting();

export interface BasCusLevel extends BasicModel<BasCusLevel> {
  code?: string; // 等级编码
  name?: string; // 等级名称
  flRate?: number; // 返利上限
  cxRate?: number; // 促销上限
}

export const basCusLevelList = (params?: BasCusLevel | any) =>
  defHttp.get<BasCusLevel>({ url: adminPath + '/bas/cus/basCusLevel/list', params });

export const basCusLevelListData = (params?: BasCusLevel | any) =>
  defHttp.post<Page<BasCusLevel>>({ url: adminPath + '/bas/cus/basCusLevel/listData', params });

export const basCusLevelForm = (params?: BasCusLevel | any) =>
  defHttp.get<BasCusLevel>({ url: adminPath + '/bas/cus/basCusLevel/form', params });

export const basCusLevelSave = (params?: any, data?: BasCusLevel | any) =>
  defHttp.postJson<BasCusLevel>({ url: adminPath + '/bas/cus/basCusLevel/save', params, data });

export const basCusLevelImportData = (
  params: UploadFileParams,
  onUploadProgress: (progressEvent: ProgressEvent) => void,
) =>
  defHttp.uploadFile<UploadApiResult>(
    {
      url: ctxPath + adminPath + '/bas/cus/basCusLevel/importData',
      onUploadProgress,
    },
    params,
  );

export const basCusLevelDelete = (params?: BasCusLevel | any) =>
  defHttp.get<BasCusLevel>({ url: adminPath + '/bas/cus/basCusLevel/delete', params });
